home *** CD-ROM | disk | FTP | other *** search
/ APC & TCP 4 / APC & TCP 4.iso / games / publicdomain / a / attacks / sources / mdgenerallib.mod < prev    next >
Text File  |  1994-05-14  |  2KB  |  62 lines

  1. IMPLEMENTATION MODULE mdgenerallib;
  2.  
  3. (*      This is a general library of procedures that I like and use in    *)
  4. (* in various ways.  Nothing special about the grouping other than that   *)
  5. (* they are things that I personally think are useful.                    *)
  6. (*         - MD                                                           *)
  7.  
  8.  
  9. FROM AmigaDOS
  10.   IMPORT   DateStampRecord, DateStamp;
  11. FROM AmigaDOSProcess
  12.   IMPORT Delay;
  13. FROM InitMathLib0
  14.   IMPORT OpenMathLib0, CloseMathLib0;
  15. FROM MathLib0
  16.   IMPORT exp, ln, real;
  17. FROM TermInOut IMPORT WriteString, WriteLn;
  18.  
  19. VAR
  20.   seed : REAL;        (* Seed for random number generator *)
  21.  
  22. (*********************************************************)
  23.  
  24. PROCEDURE MyPause (time : CARDINAL);
  25.         (* Pauses for number of seconds input *)
  26.  
  27. BEGIN
  28.    Delay (time * 50);
  29. END MyPause;
  30.  
  31. (********************************************************)
  32.  
  33. PROCEDURE RealRandom () : REAL;
  34.         (* Returns a random number in the range [0, 1). *)
  35.  
  36. VAR
  37.   temp : REAL;
  38.  
  39. BEGIN
  40.   IF NOT OpenMathLib0() THEN
  41.      WriteString("Couldn't open math libraries!"); WriteLn;
  42.      RETURN (0.5);
  43.      END;
  44.   temp := exp(5.0 * ln(seed + 3.14159)); 
  45.   seed := temp - real(LONGINT(TRUNC(temp)));
  46.   CloseMathLib0();
  47.   RETURN seed;
  48. END RealRandom;
  49.  
  50. (********************************************************)
  51.  
  52. VAR
  53.   d : DateStampRecord;
  54.  
  55. BEGIN
  56.         (******************************)
  57.         (* Init the Random Generator  *)
  58.         (******************************)
  59.   DateStamp(d);
  60.   seed := (real(d.dsMinute) + real(d.dsTick)) / 4440.0 ;
  61. END mdgenerallib.
  62.